//
// Created by yanhai on 2021/11/4.
//

#include "packet.h"
#include "flow.h"

bool Flow::operator==(const Packet &p) const
{
    if (src_addr != p.src_addr)
        return false;
    if (dst_addr != p.dst_addr)
        return false;
    if (src_port != p.src_port)
        return false;
    if (dst_port != p.dst_port)
        return false;

    return true;
}

bool Flow::CompareValue(HashTableThreadValue *v)
{
    auto p = reinterpret_cast<Packet *>(v);
    return *this == *p;
}

void Flow::InitByValue(HashTableThreadValue *v)
{
    auto p = reinterpret_cast<Packet *>(v);

    this->src_addr = p->src_addr;
    this->dst_addr = p->dst_addr;
    this->src_port = p->src_port;
    this->dst_port = p->dst_port;
}
